-
-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Fix ICSS syntax in stylesheets #10511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
bump |
|
Bump. |
|
Is this merge still being reviewed? I'm hoping this issue gets resolved soon so I can remove the craco workaround from my project. |
richardoptibrium
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes are straightforward. Surely this can be merged?
|
Thanks @thabemmz! |
|
Thanks guys. |
|
When will this be released? |
|
Is this fix included in the 4.0.3 version? |
|
This does not appear to be fixed in 4.0.3. Could someone release the fix please? |
|
When will a new version be released? So this fix can be available |
Context
After upgrading Create React App to
v4, the exported SASS variables did not work anymore in my project. This was a known issue for CRA@v4.Cause of the issue
In CRA@v4,
css-loaderwas upgraded from v3 to v4. Incss-loaderv4 there was a bug that did not handle ICSS (the syntax within CSS modules used to:importand:export) imports properly. This has been resolved by adding thecompileTypeproperty in v4.2.0.In the README of
css-loader, there is a whole section about how to configure your setup to support ICSS properly when used together with CSS modules (see here).What has been done?
compileTypeto all style rules in Webpack config of CRA. Useicssfor non-modules andmodulefor all modulesHow to test?
I tested this in my own project, but in the Create-React-App project, I verified this works by doing the following:
yarn startpackages/cra-template/template/src, renameApp.csstoApp.module.css, in the class-names replace all kebab-cased classnames to camelcase (for testing purposes)App.js, change the import toimport Styles from './App.module.css';and replace all classnames withStyles.App-like variantfoo.csswith the following content::export { black: #000000; }App.js, add the following import:import vars from './foo.css'App.js, change the<p>on line 10 to<p style={{ color: vars.black }}>:exportsyntax is working properly.(cd packages/cra-template && yarn add node-sass)and runyarn startagain.cssfiles withinpackages/cra-template/template/srcto.scss:exportsyntax is working properly, even in SCSS 🎉